import axios from "@/api/config"
import {baseURL} from "@/api/ipconfig"

var ip = baseURL.URL1
//用户管理独立机构相关 开始
export const unitOperation = {
    getUnitList: async (data) => {//获取当前用户基本信息详情
        const url = ip+'/unit/list?searchWord='+data;
        let res = await axios.get(url);
        return res;
    },
    //更新独立机构
    updateUnitName:  data=>axios.put(ip+'/unit/groupList/'+data.id+'?unitName='+data.unitName),
    addUnitName:  data=>axios.post(ip+'/unit/groupList?unitName='+data.unitName),
    //删除
    delete: async (data) => { //消息类型删除
        const url = ip+'/unit/logic';
        let res = await axios.delete(url,{
            data:data
        });
        return res;
    },
    //获取独立机构所有服务
    getServiceList:async (data) => {
        const url = ip+'/superAdmin/serviceManage?rootId='+data;
        let res = await axios.get(url);
        return res;
    },
    //修改用户最大数
    setUserMax:async (data) => {
        const url = ip+'/superAdmin/maxUser/'+data.rootId+'?maxUser='+data.maxUser;
        let res = await axios.put(url);
        return res;
    },
    //更新产品起止日期
    updateProductDate:async (data) => {
        const url = ip+'/superAdmin/expireDate/'+data.mainId;
        let res = await axios.put(url,data.productDate);
        return res;
    },
}
export const members = {
    getMembersList:data=>axios.post(ip+'/superAdmin/unit/page?rootId='+data.rootId,data.searchVo),
    //更新独立机构
    updateUnitName:  data=>axios.put(ip+'/unit/groupList/'+data.id+'?unitName='+data.unitName),
    //查询独立机构成员信息
    getMemberMessage:async (data) => { //
        const url = ip+'/superAdmin/unit/'+data;
        let res = await axios.get(url);
        return res;
    },
    //修改成员信息
    updateMember: async (data) => {
        const url = ip+'/superAdmin';
        let res = await axios.put(url,data);
        return res;
    },
    //重置密码
    resetPassword:async (data) => {
        const url = ip+'/superAdmin/resetPassword';
        let res = await axios.put(url,data);
        return res;
    },
    delete: async (data) => { 
        const url = ip+'/superAdmin';
        let res = await axios.delete(url,{
            data:data
        });
        return res;
    },
}
export const user = {
    getUserList:data=>axios.post(ip+'/superAdmin/common/page',data),
    //查询普通成员信息
    UserDetail:async (data) => { //
        const url = ip+'/superAdmin/common/look/'+data;
        let res = await axios.get(url);
        return res;
    },
    getUserMessage:async (data) => { //
        const url = ip+'/superAdmin/common/'+data;
        let res = await axios.get(url);
        return res;
    },
    //禁用启用
    disableUser:async (data) => {
        const url = ip+'/superAdmin/'+data.status+'?ids='+data.ids;
        let res = await axios.put(url,data);
        return res;
    },
    //修改
    updateUser: async (data) => {
        const url = ip+'/superAdmin';
        let res = await axios.put(url,data);
        return res;
    },
    //重置密码
    resetPassword:async (data) => {
        const url = ip+'/superAdmin/resetPassword';
        let res = await axios.put(url,data);
        return res;
    },
    delete: async (data) => { 
        const url = ip+'/superAdmin';
        let res = await axios.delete(url,{
            data:data
        });
        return res;
    },
    // 设置用户独立机构
    setUserUnit:async (data) => {
        const url = ip+'/superAdmin/common/unit?rootId='+data.rootId+'&userId='+data.userId;
        let res = await axios.put(url);
        return res;
    },
     //获取独立机构所有服务
     getServiceList:async (data) => {
        const url = ip+'/superAdmin/common/services?userId='+data;
        let res = await axios.get(url);
        return res;
    },
    //开通服务
    openServe:async (data) => {
        const url = ip+'/system/active/'+ data.mainId;
        let res = await axios.put(url,data.list);
        return res;
    },
}